import request from 'utils/request'
// 登录
const goToLogin = (params) => request.post('/api/login',params)

// 注册
const register = (params = {}) => request.post('/api/register', params)

// 更改用户信息
const alterUserInfo = (params) => request.post('/api//user/update', params)

const outLogin = () => request.post('/api/user/logout')

// 商品列表
const commodityList = (params) => request.get(`/api/product/list?keyword=${params}`)

const categoryList = () => request.get('/api/category/list')

// 商品详情
const detail = (params) => request.post(`/api/product/detail`, params)

// 购物车
const cartList = () => request.get('/api/cart/list')

// 添加购物车
const addCart = (params) => request.post('/api/cart/add', params)

//删除购物车
const delCart = (id) => request.post(`./api/cart/delete?productId=${id}`)

// 更新购物车
const updateCart = (params) => request.post('/api/cart/update', params)

// 全选
const selectAll = (status) => request.post(`/api/cart/selectAll?selected=${status}`)

// 单选
const selected = (params) => request.post(`/api/cart/select`, params)

// 订单详情
const orderDetail = (data) => request.get(`/api/order/detail?orderNo=${data}`)

// 订单列表
const orderList = (pageNum, pageSize) => request.get(`/api/order/list?pageNum=${pageNum}&pageSize=${pageSize}`)

// 订单创建
const createOrder =(params) => request.post('/api/order/create', params)

// 订单修改
const updateByOrderNo = (params) => request.post('/api/order/updateByOrderNo', params)

// 取消订单
const orderCancel = (orderNo) => request.post(`/api/order/cancel?orderNo=${orderNo}`)

// 订单完结
const orderFinish = (orderNo) => request.post(`/api/order/finish?orderNo=${orderNo}`)

// 支付接口
const orderPay = (orderNo) => request.get(`/api/order/pay?orderNo=${orderNo}`)

// 生成支付二维码
const orderQrCode= (orderNo) => request.get(`/api/order/qrcode?orderNo=${orderNo}`)

export {
  goToLogin,
  register,
  alterUserInfo,
  outLogin,
  commodityList,
  categoryList,
  detail,
  cartList,
  addCart,
  delCart,
  updateCart,
  selectAll,
  selected,
  orderDetail,
  orderList,
  createOrder,
  orderPay,
  orderCancel,
  orderFinish,
  orderQrCode,
  updateByOrderNo
}